import {Map} from 'immutable'
import { getItem } from '../../utils/common';
import * as types from '../actionTypes'

const reducer=(state=Map({
    
    currentpage:getItem('currentpage')||'/home',
    tablepages:getItem('tablepages')||JSON.stringify([{path:'/home',title:'系统首页',key:'0-0'}]),
    addtablepages:getItem('addtablepages')||''
}),action)=>{
    switch (action.type){
        case types.CHANGE_CURRENT_MENU:
            return state.set('currentpage',action.payload)
        case types.CHANGE_TABLEPAGES:
            return state.set('tablepages',action.payload)
        case types.CHANGE_ADDTABLEPAGES:
            return state.set('tablepages',action.payload)
        default:
            return state;
            
    }
}

export default reducer